package org.linlinjava.litemall.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.linlinjava.litemall.db.dao.FeedbackMapper;
import org.linlinjava.litemall.db.models.Feedback;
import org.linlinjava.litemall.db.service.FeedbackService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback>
        implements FeedbackService {

    @Override
    public IPage<Feedback> querySelective(Integer userId, String username, Integer pageNo, Integer pageSize) {
        Page<Feedback> page = new Page<>(pageNo, pageSize);
        QueryWrapper<Feedback> query = new QueryWrapper<>();
        query.eq(userId != null, "user_id", userId);
        query.like(!StringUtils.isEmpty(username), "username", username);
        return this.baseMapper.selectPage(page, query);
    }
}
